package com.ruoyi.hospital.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.hospital.domain.YlPackageType;
import com.ruoyi.hospital.service.IYlPackageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 套餐类型信息Controller
 * 
 * @author ruoyi
 * @date 2022-02-16
 */
@RestController
@RequestMapping("/type")
public class YlPackageTypeController extends BaseController
{
    @Autowired
    private IYlPackageTypeService ylPackageTypeService;

    /**
     * 查询套餐类型信息列表
     */
    @RequiresPermissions("hospital:type:list")
    @GetMapping("/list")
    public TableDataInfo list(YlPackageType ylPackageType)
    {
        startPage();
        List<YlPackageType> list = ylPackageTypeService.selectYlPackageTypeList(ylPackageType);
        return getDataTable(list);
    }

    /**
     * 导出套餐类型信息列表
     */
    @RequiresPermissions("hospital:type:export")
    @Log(title = "套餐类型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YlPackageType ylPackageType)
    {
        List<YlPackageType> list = ylPackageTypeService.selectYlPackageTypeList(ylPackageType);
        ExcelUtil<YlPackageType> util = new ExcelUtil<YlPackageType>(YlPackageType.class);
        util.exportExcel(response, list, "套餐类型信息数据");
    }

    /**
     * 获取套餐类型信息详细信息
     */
    @RequiresPermissions("hospital:type:query")
    @GetMapping(value = "/{packageTypeId}")
    public AjaxResult getInfo(@PathVariable("packageTypeId") Long packageTypeId)
    {
        return AjaxResult.success(ylPackageTypeService.selectYlPackageTypeByPackageTypeId(packageTypeId));
    }

    /**
     * 新增套餐类型信息
     */
    @RequiresPermissions("hospital:type:add")
    @Log(title = "套餐类型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YlPackageType ylPackageType)
    {
        return toAjax(ylPackageTypeService.insertYlPackageType(ylPackageType));
    }

    /**
     * 修改套餐类型信息
     */
    @RequiresPermissions("hospital:type:edit")
    @Log(title = "套餐类型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YlPackageType ylPackageType)
    {
        return toAjax(ylPackageTypeService.updateYlPackageType(ylPackageType));
    }

    /**
     * 删除套餐类型信息
     */
    @RequiresPermissions("hospital:type:remove")
    @Log(title = "套餐类型信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageTypeIds}")
    public AjaxResult remove(@PathVariable Long[] packageTypeIds)
    {
        return toAjax(ylPackageTypeService.deleteYlPackageTypeByPackageTypeIds(packageTypeIds));
    }
}
